Safe Zero-cost Coercions for Haskell (extended version)
نویسندگان
چکیده
Generative type abstractions – present in Haskell, OCaml, and other languages – are useful concepts to help prevent programmer errors. They serve to create new types that are distinct at compile time but share a run-time representation with some base type. We present a new mechanism that allows for zero-cost conversions between generative type abstractions and their representations, even when such types are deeply nested. We prove type safety in the presence of these conversions and have implemented our work in GHC.
منابع مشابه
Safe Zero - cost Coercions for Haskell ( extended version ) 1
Generative type abstractions – present in Haskell, OCaml, and other languages – are useful concepts to help prevent programmer errors. They serve to create new types that are distinct at compile time but share a run-time representation with some base type. We present a new mechanism that allows for zero-cost conversions between generative type abstractions and their representations, even when s...
متن کاملSystem FC with Explicit Kind Equality (extended version)
System FC, the core language of the Glasgow Haskell Compiler, is an explicitly-typed variant of System F with first-class type equality proofs called coercions. This extensible proof system forms the foundation for type system extensions such as type families (typelevel functions) and Generalized Algebraic Datatypes (GADTs). Such features, in conjunction with kind polymorphism and datatype prom...
متن کاملDown with kinds: adding dependent heterogeneous equality to FC (Extended Version)
FC, the core language of the Glasgow Haskell Compiler, is an explicitly-typed variant of System F with first-class type equality proofs (i.e. coercions). This extensible proof system forms the foundation for type system extensions such as type families (typelevel functions) and Generalized Algebraic Datatypes (GADTs). Such features, especially in conjunction with kind polymorphism and datatype ...
متن کاملInferring Type Isomorphisms Generically
Datatypes which differ inessentially in their names and structure are said to be isomorphic; for example, a ternary product is isomorphic to a nested pair of binary products. In some canonical cases, the conversion function is uniquely determined solely by the two types involved. In this article we describe and implement a program in Generic Haskell which automatically infers this function by n...
متن کاملCustomizing an XML-Haskell data binding with type isomorphism inference in Generic Haskell
This paper introduces a type-preserving XML Schema–Haskell data binding (or, translation) UUXML, and shows how to customize it by exploiting the theory of canonical isomorphisms to automatically infer coercions between the machine-generated types and an equivalent, more natural, user-defined set of types. We show how to implement the inference mechanism in Generic Haskell.
متن کامل